import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {//排序加贪心
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[][] arr = new int[n][2];
        for (int i = 0; i < n; i++){
            arr[i][0] = in.nextInt();
        arr[i][1] = in.nextInt();
    }
    Arrays.sort(arr, (a, b)-> {
        return a[0] <= b[0] ? -1 : 1;
    });
    int ret = 0; //记录选择个数
    int r = arr[0][1]; //记录右端点
    for (int i = 1; i < n; i++) {
        if (arr[i][0] < r) { //游重叠,更新r
            r = Math.min(arr[i][1], r);
        } else {
            ret++;
            r = arr[i][1];
        }
    }
    System.out.print(ret + 1);
    }
}